import React, { Component } from 'react'
import './index.css'
export default class index extends Component {
  handleDeleteAll = () => {
    this.props.clearCompleteItem()
  }
  checkAll = (e) => {
    this.props.checkAll(e.target.checked)
  }
  render() {
    const {todos} = this.props
    const finished = todos.filter(item => item.done).length
    return (
      <div>
        <div className="todo-footer">
          <label>
            <input checked={todos.length && finished === todos.length} type="checkbox" onChange={this.checkAll}/>
          </label>
          <span>
            <span>已完成{finished}</span> / 全部{todos.length}
          </span>
          <button className="btn btn-danger" onClick={this.handleDeleteAll}>清除已完成任务</button>
        </div>
      </div>
    )
  }
}
